package org.csu.mypetstore.service;

import org.csu.mypetstore.domain.Cart;
import org.csu.mypetstore.domain.CartItem;
import org.csu.mypetstore.persistence.CartMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class CartService {

    @Autowired
    private CartMapper cartMapper;

    public Cart getCartByUsername(String username){
        return cartMapper.getCartByUsername(username);
    }

    public void createCart(String username, BigDecimal listPrice) {
        cartMapper.createCart(username,listPrice);
    }

    public void createCartItem(CartItem cartItem) {
        cartMapper.createCartItem(cartItem);
    }
    public void updateCartItem(CartItem cartItem){
        cartMapper.updateCartItem(cartItem);
    }

    public void updateCart(BigDecimal subTotal, String username) {
        cartMapper.updateCart(subTotal,username);
    }

    public void removeCartItem(String workingItemId, String username) {
        cartMapper.removeCartItem(workingItemId,username);
    }

    public void removeCart(String username) {
        cartMapper.removeCart(username);
    }

    public void removeCartItemAll(String username) {
        cartMapper.removeCartItemAll(username);
    }

}
